﻿(function () {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();

function includeJS(incFile)
{
   document.write('<script type="text/javascript" src="'+ incFile+ '"></script>');
}

//Popup Login
$(document).ready(function () {
    //Chỉ nhập số (number) vào input
    $(".number").keypress(function (e) {
        if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
            return false;
        }
    });

    $('.userIn').hover(
        function () { $('.menu_user').slideDown("fast"); },
        function () { $('.menu_user').slideUp("fast"); }
    );
    // To top
    $(window).scroll(function () {
        if ($(this).scrollTop() != 0) {
            $('.to_top').fadeIn();
        } else {
            $('.to_top').fadeOut();
        }
    });
    $('.to_top').click(function () {
        $('body,html').animate({ scrollTop: 0 }, 800);
    });
    //
    $('#search_quick').click(function () {
        var strKeyWord = $('#txtKeyword').val();
        window.location.href = "/tim-kiem?q=" + strKeyWord;
    });
    //
    var currentDate = new Date();
    $(".date").datepicker({ dateFormat: 'dd/mm/yy' });

    /*------Menu chird tin tức------*/
    $("#news-P").hover(function () {
        $('.chird-tintuc').show();
    }, function () {
        $('.chird-tintuc').hide();
    });

});


/*=====================liblary function================================*/
jQuery.fn.errorItem = function (message) {
    $(this).addClass("error-item");
    $(this).attr("placeholder", message);
};
/*=====================================================================*/

//Goto Error
jQuery.fn.goToError = function () {
    $('html,body').animate({ scrollTop: ($("#notifition").offset().top - 10) }, 'slow');
};

// Check định dạng Email
function xfomatEmail(email) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\ ".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
}